Skip to content

Harden client-side rendering and build inputs#83

Merged
VatsalSy merged 7 commits intomainfrom
security/harden-client-and-build-inputs
Apr 1, 2026
Merged

Harden client-side rendering and build inputs#83
VatsalSy merged 7 commits intomainfrom
security/harden-client-and-build-inputs

Conversation

@VatsalSy
Copy link
Copy Markdown
Member

@VatsalSy VatsalSy commented Apr 1, 2026

Summary

  • render command palette search titles and excerpts with DOM nodes instead of innerHTML
  • replace runtime Font Awesome injection with a pinned stylesheet + SRI across layouts, and escape teaching-course head metadata/JSON-LD
  • sanitize featured-paper clones and only recreate trusted YouTube nocookie iframes with sandboxing
  • stop bootstrap-by-download setup behavior, pin the remaining GitHub App token action, and harden SEO URL/config parsing

Context

These changes come from reviewing older security-scan patches against current main. I applied the ones that still made sense, adapted the featured-iframe fix so it keeps safe embeds working, and confirmed update-search.yml was already pinned before this branch.

Testing

  • npx eslint assets/js/command-palette.js assets/js/main.js
  • npx jest tests/command-palette-stale-search.test.js tests/featured-papers-regression.test.js --runInBand --coverage=false
  • bash -n scripts/setup.sh
  • ruby -c scripts/generate_seo_tags.rb

VatsalSy added 4 commits April 1, 2026 12:49
Build command result rows with DOM nodes so search titles and excerpts are inserted as text instead of interpolated into innerHTML.

Keep icon rendering unchanged because those strings are defined in-repo, and add a regression test that proves HTML in search results is displayed as text rather than creating DOM nodes.
Replace runtime Font Awesome injection in each layout with a fixed CDN stylesheet reference protected by SRI.

This removes the hostname-based script/css branching, avoids loading a kit script into the page head, and keeps icon rendering consistent across local and deployed pages.
Sanitize cloned featured-paper elements before inserting them into the homepage card list.

Rebuild iframe-only media as trusted YouTube nocookie embeds with explicit sandbox and referrer policy settings, and add coverage for both the preserved safe embed path and rejected untrusted iframe sources.
Stop bootstrap-by-download behavior in setup.sh when Ruby or Node.js are missing, pin the remaining GitHub App token action by commit SHA, and switch SEO config loading to YAML.safe_load.

Also normalize internal SEO output paths through URI parsing and cleanpath checks before writing under _site so crafted URLs cannot escape the build output directory.
Copilot AI review requested due to automatic review settings April 1, 2026 11:51
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 87bb1a290f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the site’s client-side rendering and build-time inputs by reducing HTML injection surfaces, tightening iframe/embed handling, and improving supply-chain pinning for external dependencies and GitHub Actions.

Changes:

  • Render command palette result titles/excerpts via DOM text nodes (avoids innerHTML for untrusted fields) and add regression coverage.
  • Sanitize featured paper card content and only recreate trusted YouTube nocookie iframes with sandboxing; add regression coverage for untrusted iframe sources.
  • Harden setup/SEO tooling and dependency inputs (safe YAML load + URL/path normalization, stop auto-install-by-download, pin GitHub Action, replace runtime Font Awesome injection with pinned stylesheet + SRI).

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
assets/js/command-palette.js Uses DOM nodes + textContent for result title/excerpt rendering.
assets/js/main.js Sanitizes featured-paper clones; recreates only trusted YouTube nocookie iframes with security attributes.
scripts/generate_seo_tags.rb Uses safe YAML loading; strengthens URL parsing/normalization and prevents unsafe output paths.
scripts/setup.sh Stops auto-installing Ruby/Node via downloaded installers; requires trusted pre-install.
tests/command-palette-stale-search.test.js Adds XSS regression test ensuring title/excerpt render as text.
tests/featured-papers-regression.test.js Extends featured-paper tests for iframe sanitization and untrusted iframe dropping.
.github/workflows/sync-org-profile-publications.yml Pins actions/create-github-app-token to a specific commit SHA.
_layouts/default.html Replaces runtime Font Awesome injection with pinned CDN stylesheet + SRI.
_layouts/history.html Replaces runtime Font Awesome injection with pinned CDN stylesheet + SRI.
_layouts/join-us.html Replaces runtime Font Awesome injection with pinned CDN stylesheet + SRI.
_layouts/research.html Replaces runtime Font Awesome injection with pinned CDN stylesheet + SRI.
_layouts/team.html Replaces runtime Font Awesome injection with pinned CDN stylesheet + SRI.
_layouts/teaching.html Replaces runtime Font Awesome injection with pinned CDN stylesheet + SRI.
_layouts/teaching-course.html Escapes head metadata, switches JSON-LD fields to jsonify, and replaces Font Awesome injection with pinned CDN stylesheet + SRI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

VatsalSy added 2 commits April 1, 2026 14:53
Replace inherited featured iframe permissions with a fixed allowlist and stronger sandboxing. Also let setup.sh bootstrap the repo-pinned Ruby through rbenv even when ruby is not initially on PATH, matching the script's documented behavior.
Fix the still-relevant stale findings in the current tree: protect command-palette external links with noopener, build the research tag filter with DOM nodes instead of HTML string interpolation, stop reparsing research badge paragraph content through innerHTML, replace the remaining Dropbox-hosted research image with a local asset, and repair fix-quotes.sh so it no longer risks emptying files when run.
Copilot AI review requested due to automatic review settings April 1, 2026 16:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@VatsalSy VatsalSy merged commit 326c58a into main Apr 1, 2026
4 checks passed
@VatsalSy VatsalSy deleted the security/harden-client-and-build-inputs branch April 1, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants